package com.dks.mapper;

import com.dks.models.student.UserClassHourPackage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface UserClassHourPackageMapper {

    int insert(UserClassHourPackage userClassHourPackage);

    UserClassHourPackage select(@Param("id") Long id, @Param("userId") Long userId);

    UserClassHourPackage selectById(@Param("id") Long id);

    List<UserClassHourPackage> getList(@Param("userId") Long userId, @Param("classHourPackageType") String classHourPackageType);

    /**
     * latelyParam 代表查找有效期最短and购买时间最前的课时包
     * */
    List<UserClassHourPackage> getAvailableList(@Param("userId") Long userId, @Param("classHourPackageType") String classHourPackageType , @Param("latelyParam")String latelyParam);

    /**
     * 冻结课时
     */
    int frozenClassHour(@Param("id") long id, @Param("classHour") int classHour, @Param("userId") long userId);

    /**
     * 解冻课时
     */
    int unFrozenClassHour(@Param("id") long id, @Param("classHour") int classHour, @Param("userId") long userId);

    List<UserClassHourPackage> list(@Param("userId") Long userId, @Param("status") String status);

    Integer openCard(@Param("id") Long id, @Param("openCardTime") LocalDateTime openCardTime, @Param("expireTime") LocalDateTime expireTime);

    int transferApply(@Param("id") Long id, @Param("userId") Long userId, @Param("targetUserId") Long targetUserId);

    int refundApply(@Param("id") Long id, @Param("userId") Long userId);

    UserClassHourPackage selectAvailableClassHourCount(@Param("userId") Long userId);

    List<Integer> userClassHourPackageIdList(Map<String, Object> map);

    Integer updateCountHour(Map<String, Object> map);

    Integer updatePayStatus(@Param("id") Long id, @Param("payStatus") Integer payStatus, @Param("payTime") Date payTime);

    int transferApplyCancel(@Param("id") Long id, @Param("userId") Long userId);

    int updatePayAmount(@Param("id") Long id, @Param("payAmount") Integer payAmount);
}
